package com.zusmart.core.config.source;

import java.io.InputStream;
import java.util.Properties;

import com.zusmart.core.config.ConfigSource;
import com.zusmart.core.config.support.AbstractConfigSourceConverter;

public class ConfigSourceConverterForProperties extends AbstractConfigSourceConverter {

	@Override
	public String getSupportExtension() {
		return ConfigSourceForProperties.EXTENSION;
	}

	@Override
	protected ConfigSource doConvert(InputStream inputStream, String fileName) throws Exception {
		try {
			Properties properties = new Properties();
			properties.load(inputStream);
			return new ConfigSourceForProperties(fileName, properties);
		} finally {
			inputStream.close();
		}
	}

}